#include "PythonInterpreter.h"
#include <iostream>

using namespace boost::python;


PythonInterpreter::PythonInterpreter()
{
	lang = "python";
	mOutput.clear();
	mCurrentStatement.clear();

	Py_Initialize();

	PyRun_SimpleString("import sys\n"
						"sys.path.append('.')\n"
						"import PythonBinding\n");

	try {
			object main_module = import("__main__");
			object main_namespace = main_module.attr("__dict__");

//			object hello = boost::python::import("hello");
			
		} 
		catch(...) {
			PyErr_Print();
			PyErr_Clear();

		}
}

PythonInterpreter::~PythonInterpreter()
{
//	Py_Finalize();
}

void PythonInterpreter::insertLine(std::string& line)
{
//	mCurrentStatement += " ";
//	mCurrentStatement += line;
	PyRun_SimpleString(line.c_str());
//	object exec(line);

	mPrompt = PI_PROMPT;
	mCurrentStatement.clear();
}

// Callback for python to provide output.
int PythonInterpreter::insertOutputFromPython()
{
//	if (PyCallable_Check(pFunc)) {
//			PyObject_CallObject(pFunc, NULL);
//		} else {
//			PyErr_Print();
//		}



	return 0;
}
